

<?php
function Register($FirstName, $LastName, $UserName, $Password, $RPassword, $Birthday, $Gender, $Phone, $College, $Department)
  {
 include("db_util.php");
putenv("ORACLE_HOME=/usr/local/libexec/oracle/app/oracle/product/11.2.0/client_1");
$connection=DbConnect();
if(!$connection)
		echo "DisConnected!<br>";
		
$query='select * from Student where email=\'' . $UserName . '\''; 
		


$statement = oci_parse($connection, $query);

	oci_execute($statement);
	
	$row = oci_fetch_array($statement, OCI_ASSOC+OCI_RETURN_NULLS);
	
//$statement=QueryExecution($connection,$query);
if(!$row)
		 {
		 $query = "select max(SID) as MAX from student";
			$stmt = oci_parse($connection, $query);
			oci_execute($stmt);
			$max_id = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS);
			$next_id = $max_id["MAX"] + 1;
			oci_free_statement($stmt);
		 $query='Insert into Student values(' . $next_id . ',\''. $FirstName . '\',\'' . $LastName . '\',null,\'' . $Department . '\', \'\',\'' . $Gender . '\',\'' . $UserName . '\',  \'\',1,\'' . $Password . '\', null, null,\'online\',\'\')';
		echo $query;
		 $statement = oci_parse($connection, $query);
		 oci_execute($statement);
	DbConnectionClose($connection,  $statement);
	session_start(); 
   
    $_SESSION["login"] = true;  
$_SESSION["StuID"] =$next_id;
	 header('Location: Personal.php') ;
		 }
		 else {
		 
		 echo "The username already existed!!";
		 DbConnectionClose($connection,  $statement);
		 return false;
		 }
		


		//DbConnectionClose($connection,  $statement);
		return true;

  }
 //LogIn($_POST["uname"],$_POST["pwd"]); 
 
 

?>

